/*  1:   */ package org.jetbrains.lang.manifest.highlighting;
/*  2:   */ 
/*  3:   */

import com.intellij.codeInspection.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.lang.manifest.ManifestBundle;
import org.jetbrains.lang.manifest.psi.Header;
import org.jetbrains.lang.manifest.psi.ManifestFile;
import org.jetbrains.lang.manifest.psi.ManifestTokenType;
import org.jetbrains.lang.manifest.psi.Section;

import java.util.List;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */
/* 13:   */
/* 14:   */
/* 15:   */
/* 16:   */
/* 17:   */
/* 18:   */
/* 19:   */
/* 20:   */ 
/* 21:   */ public class MissingFinalNewlineInspection
/* 22:   */   extends LocalInspectionTool
/* 23:   */ {
/* 24:   */   public ProblemDescriptor[] checkFile(@NotNull PsiFile paramPsiFile, @NotNull InspectionManager paramInspectionManager, boolean paramBoolean)
/* 25:   */   {
/* 26:47 */     if (paramPsiFile == null) {
/* 27:47 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/lang/manifest/highlighting/MissingFinalNewlineInspection", "checkFile" }));
/* 28:   */     }
/* 29:47 */     if (paramInspectionManager == null) {
/* 30:47 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/lang/manifest/highlighting/MissingFinalNewlineInspection", "checkFile" }));
/* 31:   */     }
/* 32:47 */     if ((paramPsiFile instanceof ManifestFile))
/* 33:   */     {
/* 34:48 */       String str = paramPsiFile.getText();
/* 35:49 */       if ((str != null) && (str.length() > 0) && (!StringUtil.endsWith(str, "\n")))
/* 36:   */       {
/* 37:50 */         List localList = ((ManifestFile)paramPsiFile).getSections();
/* 38:51 */         assert (localList.size() > 0) : str;
/* 39:52 */         Section localSection = (Section)localList.get(localList.size() - 1);
/* 40:53 */         ProblemDescriptor localProblemDescriptor = paramInspectionManager.createProblemDescriptor(localSection.getLastChild(), ManifestBundle.message("inspection.newline.message", new Object[0]), new AddNewlineQuickFix(localSection, null), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, paramBoolean);
/* 41:   */         
/* 42:   */ 
/* 43:   */ 
/* 44:57 */         return new ProblemDescriptor[] { localProblemDescriptor };
/* 45:   */       }
/* 46:   */     }
/* 47:61 */     return null;
/* 48:   */   }
/* 49:   */   
/* 50:   */   private static class AddNewlineQuickFix
/* 51:   */     implements LocalQuickFix
/* 52:   */   {
/* 53:   */     private final Section a;
/* 54:   */     
/* 55:   */     AddNewlineQuickFix(Section paramSection, MissingFinalNewlineInspection.0 param0)
/* 56:   */     {
/* 57:64 */       this(paramSection);
/* 58:   */     }
/* 59:   */     
/* 60:   */     private AddNewlineQuickFix(Section paramSection)
/* 61:   */     {
/* 62:68 */       this.a = paramSection;
/* 63:   */     }
/* 64:   */     
/* 65:   */     @NotNull
/* 66:   */     public String getName()
/* 67:   */     {
/* 68:74 */       String tmp9_6 = ManifestBundle.message("inspection.newline.fix", new Object[0]);
/* 69:74 */       if (tmp9_6 == null) {
/* 70:74 */         throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/lang/manifest/highlighting/MissingFinalNewlineInspection$AddNewlineQuickFix", "getName" }));
/* 71:   */       }
/* 72:74 */       return tmp9_6;
/* 73:   */     }
/* 74:   */     
/* 75:   */     @NotNull
/* 76:   */     public String getFamilyName()
/* 77:   */     {
/* 78:80 */       String tmp9_6 = ManifestBundle.message("inspection.group", new Object[0]);
/* 79:80 */       if (tmp9_6 == null) {
/* 80:80 */         throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/lang/manifest/highlighting/MissingFinalNewlineInspection$AddNewlineQuickFix", "getFamilyName" }));
/* 81:   */       }
/* 82:80 */       return tmp9_6;
/* 83:   */     }
/* 84:   */     
/* 85:   */     public void applyFix(@NotNull Project paramProject, @NotNull ProblemDescriptor paramProblemDescriptor)
/* 86:   */     {
/* 87:85 */       if (paramProject == null) {
/* 88:85 */         throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/lang/manifest/highlighting/MissingFinalNewlineInspection$AddNewlineQuickFix", "applyFix" }));
/* 89:   */       }
/* 90:85 */       if (paramProblemDescriptor == null) {
/* 91:85 */         throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/lang/manifest/highlighting/MissingFinalNewlineInspection$AddNewlineQuickFix", "applyFix" }));
/* 92:   */       }
/* 93:85 */       PsiElement localPsiElement = this.a.getLastChild();
/* 94:86 */       if ((localPsiElement instanceof Header)) {
/* 95:87 */         localPsiElement.getNode().addLeaf(ManifestTokenType.NEWLINE, "\n", null);
/* 96:   */       }
/* 97:   */     }
/* 98:   */   }
/* 99:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.lang.manifest.highlighting.MissingFinalNewlineInspection

 * JD-Core Version:    0.7.0.1

 */